﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace WpfMesDemo2.Converters
{
    public class StatusToBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                return Brushes.Black;

            string status = value.ToString().ToLower();

            switch (status)
            {
                case "成功":
                case "已完成":
                    return Brushes.Green;

                case "错误":
                case "失败":
                    return Brushes.Red;

                case "警告":
                    return Brushes.Orange;

                case "正在加载":
                case "处理中":
                    return Brushes.Blue;

                default:
                    return Brushes.Black;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
